package gui;

import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.io.File;
import java.text.DateFormat;
import java.util.Date;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.table.TableCellRenderer;

import logic.file.IFile;

//dziedziczenie po JLabel zapewnie reusing i przez to lepszą skalowalność
@SuppressWarnings("serial")
public class FileDateCellRenderer extends JLabel implements TableCellRenderer {
	
	UIDefaults defaults = javax.swing.UIManager.getDefaults();

	@Override
	public Component getTableCellRendererComponent(JTable table, Object value,
			boolean isSelected, boolean hasFocus, int row, int column) {
		
		setOpaque(true);
		setBackground(Color.WHITE);
		
		if (isSelected) {
			setBackground(defaults.getColor("Table.selectionBackground"));
		}
		
		setText(DateFormat.getDateTimeInstance().format(new Date((long) value)));
		setFont((Font) UIManager.get("Table.font"));
		setBorder(BorderFactory.createEmptyBorder());
		
		return this;
	}

}
